﻿using BaseWPFControl.ToolDialog;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using UserControl = System.Windows.Controls.UserControl;

namespace ZerosToDo.SubView;

/// <summary>
/// NotepadItem.xaml 的交互逻辑
/// </summary>
public partial class NotepadItem : UserControl
{
    public NotepadItem(UIElement _element)
    {
        InitializeComponent();
        PART_Content.Content = _element;
    }

    private void Button_Copy_Click(object sender, RoutedEventArgs e)
    {
        // 复制文本到剪贴板
        if (PART_Content.Content is TextBlock _text_block)
        {
            Clipboard.SetText(_text_block.Text);
        }
        // 复制图片到剪贴板
        else if (PART_Content.Content is Image _image)
        {
            ImageSource _image_source = _image.Source;
            Clipboard.SetImage((BitmapSource)_image_source);
        }
    }

    private void Button_Delete_Click(object sender, RoutedEventArgs e)
    {
        if (MessageDialog.ShowAsWindow("确认删除？"))
        {
            App.NotepadWindow.DeleteItem(this);
        }
    }
}
